using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BlueFinity.mvNET.CoreObjects;
using IBMU2.UODOTNET;
using mvLibrary.Helpers;


namespace mvLibrary
{
    public partial class HelpForm : Form
    {
        private string _user;
        private string _helpText;
        private string _formName;
        private readonly ProgramCaller programCaller;

        public UniSession UniSession { get; set; }
        public string User
        {
            get { return _user; }
            set { _user = value; }
        }
        public string HelpText
        {
            get { return _helpText; }
            set { _helpText = value; }
        }
        public string FormName
        {
            get { return _formName; }
            set { _formName = value; }
        }
        public HelpForm()
        {
            InitializeComponent();
            programCaller = ProgramCaller.Instance;
        }

        private void HelpFor_Load(object sender, EventArgs e)
        {
            textHelpForm.Text = _helpText;
            string userNotes = string.Empty;
            string showHelpMode = "R";
            try
            {
                UniSubroutine subRoutine = programCaller.subRoutineManager.CreateSubRoutine(UniSession, "SHOW.HELP", _formName, _user, userNotes, showHelpMode);
                textUserNotes.Text = subRoutine.GetArg(2);
            }
            catch
            {
                textUserNotes.Text = "";
            }

            labelFormName.Text = "Formulario " + _formName;
            textUserNotes.Focus();
        }

        private void butSave_Click(object sender, EventArgs e)
        {
            try
            {
                string userNotes = textUserNotes.Text;
                string showHelpMode = "W";
                programCaller.subRoutineManager.CreateSubRoutine(UniSession, "SHOW.HELP", _formName, _user, userNotes, showHelpMode);
            }
            catch (mvException mvEx)
            {
                MessageBox.Show("Error al grabar. \n\nMensaje del servidor: " + mvEx.Message);
            }

        }






    }
}

